Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an add-admin action #220

Merged
merged 32 commits into from
Feb 3, 2023
Merged

Add an add-admin action #220

merged 32 commits into from
Feb 3, 2023

Conversation

nrobinaubertin
Copy link
Contributor

@nrobinaubertin nrobinaubertin commented Jan 22, 2023

The goal is to add a add-admin action to the charm that uses a modified version of indico CLI tool.
I added a click command group (via plugin) to allow the indico autocreate admin <email> <password> command.

actions.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@jdkandersson jdkandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't finished this review yet, there are some broad questions about whether this should be a CLI or it should be in the charm source code. Let's address that first and then I'll finish the review

files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
files/src/indico/cli/user.py Outdated Show resolved Hide resolved
@nrobinaubertin
Copy link
Contributor Author

Haven't finished this review yet, there are some broad questions about whether this should be a CLI or it should be in the charm source code. Let's address that first and then I'll finish the review

Sorry, it probably wasn't obvious from the PR description. I'm patching a file from the source code of indico (here is the source).
I decided to do it that way to avoid fiddling with their internal database structure.

So I want to do it in a way that is simple, ideally robust to some unrelated changes in indico and better, that breaks when there are changes that would affect this change.
I thought of 3 ways to do it:

  1. wget the source and adding my bit at the end
  2. wget the source and apply a git patch
  3. replacing the whole file

I decided to replace the whole file (seemed simpler, but maybe not). But doing that, I find it better to avoid touching the code that the indico team/community wrote around the block that I'm adding. Eventually, I plan to make a PR on indico's side

@jdkandersson
Copy link
Contributor

Haven't finished this review yet, there are some broad questions about whether this should be a CLI or it should be in the charm source code. Let's address that first and then I'll finish the review

Sorry, it probably wasn't obvious from the PR description. I'm patching a file from the source code of indico (here is the source). I decided to do it that way to avoid fiddling with their internal database structure.

So I want to do it in a way that is simple, ideally robust to some unrelated changes in indico and better, that breaks when there are changes that would affect this change. I thought of 3 ways to do it:

  1. wget the source and adding my bit at the end
  2. wget the source and apply a git patch
  3. replacing the whole file

I decided to replace the whole file (seemed simpler, but maybe not). But doing that, I find it better to avoid touching the code that the indico team/community wrote around the block that I'm adding. Eventually, I plan to make a PR on indico's side

So are we making any modifications from that source or is it just vending in that file? with no changes?

@nrobinaubertin
Copy link
Contributor Author

nrobinaubertin commented Jan 25, 2023

So are we making any modifications from that source or is it just vending in that file? with no changes?

I'm adding the block with the command "autocreate"

@cli.command("autocreate")

@jdkandersson
Copy link
Contributor

So are we making any modifications from that source or is it just vending in that file? with no changes?

I'm adding the block with the command "autocreate"

@cli.command("autocreate")

Would it be possible to move that to the charm source code?

@gregory-schiano
Copy link
Contributor

Haven't finished this review yet, there are some broad questions about whether this should be a CLI or it should be in the charm source code. Let's address that first and then I'll finish the review

Sorry, it probably wasn't obvious from the PR description. I'm patching a file from the source code of indico (here is the source). I decided to do it that way to avoid fiddling with their internal database structure.

So I want to do it in a way that is simple, ideally robust to some unrelated changes in indico and better, that breaks when there are changes that would affect this change. I thought of 3 ways to do it:

  1. wget the source and adding my bit at the end
  2. wget the source and apply a git patch
  3. replacing the whole file

I decided to replace the whole file (seemed simpler, but maybe not). But doing that, I find it better to avoid touching the code that the indico team/community wrote around the block that I'm adding. Eventually, I plan to make a PR on indico's side

The risk here is that upgrading indico version could lead to incompatibility. Which means we'll have to pay attention to port the change on that file everytime we update indico.
A patch is a bit more flexible but still not ideal
Ideally we should submit this change to indico project to have it as part of the project itself.
Wouldn't it be possible to add an extra file independent that adds this new command ?

@nrobinaubertin
Copy link
Contributor Author

Wouldn't it be possible to add an extra file independent that adds this new command ?

I thought of adding a new module in its own file. But I still have to load it therefore change the core.py file of indico's CLI

@gregory-schiano
Copy link
Contributor

Wouldn't it be possible to add an extra file independent that adds this new command ?

I thought of adding a new module in its own file. But I still have to load it therefore change the core.py file of indico's CLI

After investigating and discussing with Niels, Indico supports plugins that can extend CLI
I suggested to have a look at this as it will be less intrusive and more generic

plugins/autocreate/autocreate/cli.py Outdated Show resolved Hide resolved
plugins/autocreate/autocreate/cli.py Outdated Show resolved Hide resolved
plugins/autocreate/autocreate/cli.py Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
tests/unit/test_actions.py Outdated Show resolved Hide resolved
@nrobinaubertin nrobinaubertin marked this pull request as ready for review January 26, 2023 17:05
Copy link
Contributor

@jdkandersson jdkandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any integration tests?

actions.yaml Outdated Show resolved Hide resolved
plugins/autocreate/autocreate/cli.py Outdated Show resolved Hide resolved
plugins/autocreate/autocreate/cli.py Outdated Show resolved Hide resolved
plugins/autocreate/autocreate/cli.py Outdated Show resolved Hide resolved
plugins/autocreate/autocreate/plugin.py Outdated Show resolved Hide resolved
plugins/autocreate/setup.cfg Outdated Show resolved Hide resolved
plugins/autocreate/setup.cfg Outdated Show resolved Hide resolved
plugins/autocreate/setup.cfg Show resolved Hide resolved
plugins/autocreate/setup.cfg Outdated Show resolved Hide resolved
tests/unit/test_actions.py Show resolved Hide resolved
indico.Dockerfile Outdated Show resolved Hide resolved
Copy link
Collaborator

@arturo-seijas arturo-seijas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the PR description to match the current action params?

@amandahla
Copy link
Contributor

Wouldn't it be possible to add an extra file independent that adds this new command ?

I thought of adding a new module in its own file. But I still have to load it therefore change the core.py file of indico's CLI

After investigating and discussing with Niels, Indico supports plugins that can extend CLI I suggested to have a look at this as it will be less intrusive and more generic

Just to add another option to consider, it could be possible to pass input to the "indico user create --admin" command using expect:
https://phoenixnap.com/kb/linux-expect

So wouldn't be necessary to change anything in Indico.

@nrobinaubertin
Copy link
Contributor Author

Just to add another option to consider, it could be possible to pass input to the "indico user create --admin" command using expect

Yes, this was considered during the discussions that lead to a conclusion to this thread.
The answer of David was that even using that way of doing things would call for more e2e testing.

jdkandersson
jdkandersson previously approved these changes Feb 3, 2023
Copy link
Contributor

@jdkandersson jdkandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, still seems to be some issues with the lint command

Thanks for your resilience with all the feedback!

@nrobinaubertin
Copy link
Contributor Author

nrobinaubertin commented Feb 3, 2023

Looking good, still seems to be some issues with the lint command

The issue here is that the lint tests are running on focal (python 3.8) and the pypi package for indico 3.2 is not compatible with it.
I think that the best course of action is to remove the plugin from the charm lint tests and move it to a section just for it.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2023

Test coverage for d7db4c4

Name           Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------
src/charm.py     303      6     82     12    95%   124->exit, 140, 144, 497->501, 498->exit, 545->548, 648->687, 765-766, 828->exit, 848->864, 850->859, 859->864, 872-873, 916->exit
----------------------------------------------------------
TOTAL            303      6     82     12    95%

Static code analysis report

Run started:2023-02-03 16:23:13.101669

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 1801
  Total lines skipped (#nosec): 4
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

Copy link
Collaborator

@arturo-seijas arturo-seijas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@amandahla amandahla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nrobinaubertin nrobinaubertin merged commit 0094ce0 into main Feb 3, 2023
@nrobinaubertin nrobinaubertin deleted the add-user branch February 3, 2023 19:10
@jdkandersson
Copy link
Contributor

The integration tests failed...

@jdkandersson
Copy link
Contributor

If the lint checks fail for Ubuntu 20.04, does the add-admin action actually work on Python 3.8? It looks like it wasn't possible to install indico on Python 3.8?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants